<!DOCTYPE>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <title>用户添加</title>
    <link href="/css/style2.css" rel="stylesheet" type="text/css"/>

    <link href="/css/select.css" rel="stylesheet" type="text/css"/>
    <script src="/js/jquery.js" type="text/javascript"></script>
    <script src="/js/jquery.idTabs.min.js" type="text/javascript"></script>
    <script src="/js/select-ui.min.js" type="text/javascript"></script>
    <script src="/js/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        KE.show({
            id: 'content7',
            cssPath: './index.css'
        });
    </script>

    <script type="text/javascript">
        $(document).ready(function (e) {
            $(".select1").uedSelect({
                width: 345
            });
            $(".select2").uedSelect({
                width: 167
            });
            $(".select3").uedSelect({
                width: 100
            });
        });
    </script>
    <script language="javascript">

        function saveButton() {
            document.forms[0].action = "/user/insert";
            let form = $("#form").serializeArray()

            console.log(form[9]);
            if (form[0].value == '' || form[1].value == '' || form[2].value == '' || form[3].value == '') {
                alert('请输入必填项')
                return
            } else if (form[1].value != form[2].value) {
                alert("两次密码不一样，请重新输入！")
                return
            } else if (form[6].value.length != 11) {
                alert('手机号码格式不正确！')
                return
            } else if (form[7].value.indexOf('-') == -1) {
                alert('时间分割请以“-”！')
                return
            } else if (!form[8].value.match(
                '^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$')) {
                alert('邮箱格式不正确！')
                return
            } else if (form[9].value == '--请选择--') {
                alert('请选择权限！')
                return
            }

            document.forms[0].submit();
        }
    </script>


</head>

<body>
<form action="/user/insert" id="form" method="post">
    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <li><a href="userSearch">用户管理</a></li>
            <li><a href="#">添加用户</a></li>
        </ul>
    </div>

    <div class="formbody">

        <div class="formtitle"><span>基本信息</span></div>

        <ul class="forminfo">
            <li>
                <label>工号 <font color="red">*</font></label>
                </label><input class="dfinput" id="account" name="account" type="text"/></li>
            <li>
                <label>密码 <font color="red">*</font></label>
                <input class="dfinput" id="password" name="password" type="password"/>
            </li>
            <li>
                <label>确认密码 <font color="red">*</font></label><input class="dfinput" id="password1" name="password1"
                                                                     type="password"/>
            </li>
            <li>
                <label>姓名 <font color="red">*</font></label>
                </label><input class="dfinput" id="name" name="name" type="text"/>
            </li>
            <li><label>部门</label>
                <div class="vocation">
                    <select class="select3" name="departmentId">
                        <option>--请选择--</option>
                        <option th:each="p:${dept}" th:text="${p.departmentName}" th:value="${p.departmentName}">研发一部
                        </option>
                    </select>
                </div>
            </li>
            <li>
                <label>性别</label>
                <cite><input checked="checked" name="sex" type="radio" value="0"/>
                    男&nbsp;&nbsp;&nbsp;&nbsp;
                    <input name="sex" type="radio" value="1"/>
                    女</cite></li>
            <li><label>手机号码 <font color="red">*</font></label><input class="dfinput" id="mobile" name="mobile"
                                                                     type="text" value=""/></li>
            <li><label>出生日期<font color="red">*</font></label><input class="dfinput" id="birthday" name="birthday"
                                                                    onClick="WdatePicker({startDate:'',dateFmt:'yyyy-MM-dd'})"
                                                                    type="text"
                                                                    value=""/></li>
            <li><label>邮箱 <font color="red">*</font></label><input class="dfinput" id="email" name="email" type="text"/>


            <li><label>权限 <font color="red">*</font></label>
                <div class="vocation">
                    <select class="select3" name="userType">
                        <option>--请选择--</option>
                        <option value="0">超级管理员</option>
                        <option value="1">部门主管</option>
                        <option value="2">普通员工</option>
                    </select>
                </div>
            </li>

            <li><label>&nbsp;</label><input class="btn" name="" onclick="saveButton()" type="button" value="确认保存"/></li>
            <li><p id="tishi" style="color:red;"></p></li>
        </ul>
    </div>
</form>
</body>
</html>
